Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the incorrect Affine - Projective implementation #822

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

winderica
Copy link
Contributor

@winderica winderica commented Apr 23, 2024

Description

This PR fixes the incorrect implementation of subtraction between an affine point and a projective point by flipping the position of subtrahend and minuend.

closes: #821

No performance regression due to this PR is observed (tested on Intel Core i9-12900k):

Arithmetic for Bls12_381::G1/Subtraction
                        time:   [443.13 ns 445.52 ns 448.43 ns]
                        change: [-0.7657% -0.0664% +0.5887%] (p = 0.86 > 0.05)
                        No change in performance detected.
Found 8 outliers among 100 measurements (8.00%)
  4 (4.00%) high mild
  4 (4.00%) high severe

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to GitHub issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code (N/A)
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the GitHub PR explorer

@winderica winderica requested review from a team as code owners April 23, 2024 12:23
@winderica winderica requested review from z-tech, Pratyush and mmagician and removed request for a team April 23, 2024 12:23
@@ -305,14 +305,14 @@ impl<P: SWCurveConfig, T: Borrow<Self>> Sub<T> for Affine<P> {
impl<P: SWCurveConfig> Sub<Projective<P>> for Affine<P> {
type Output = Projective<P>;
fn sub(self, other: Projective<P>) -> Projective<P> {
other - self
self.into_group() - other
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.into_group() - other
self + (-other)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out the better solution! Wasn't aware that we can do this 😂

Copy link
Member

@Pratyush Pratyush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR and the fix!

@Pratyush Pratyush added this pull request to the merge queue Apr 25, 2024
Merged via the queue into arkworks-rs:master with commit 065cd24 Apr 25, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Affine - Projective produces incorrect results
2 participants